package uk.ac.bath.base;

import java.io.StringWriter;


public class VectorState {

    public Value[] v;
    public int n;

    protected VectorState() {
    }

    public VectorState(VectorState vec) {
        v = vec.v;
        n = vec.n;
    }

    public VectorState(int n, Value proto) {
        this.n = n;
        v = new Value[n];
        for (int i = 0; i < n; i++) {
            v[i] = (Value) (proto.clone());
        }
    }

    public int size() {
        return n;
    }

    public Value at(int i) {
        // if (i < 0) i += n *(1-(i/n));
        return v[i];
    }

    public void setAll(float val) {
        for (int i = 0; i < n; i++) {
            v[i].set(val);
        }
    }

    public void readString(String data) {
        for (int i = 0; i < v.length; i++) {
            v[i].readString(data);
        }
    }

    public String toString() {
        StringWriter w = new StringWriter(v.length);
        for (int i = 0; i < v.length; i++) {
            w.write(v[i].toString());
            w.write(" ");
        }
        return w.toString();
    }
}


